home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / src / pt-const.cc < prev    next >
C/C++ Source or Header  |  1996-11-19  |  3KB  |  149 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if defined (__GNUG__)
  24. #pragma implementation
  25. #endif
  26.  
  27. #ifdef HAVE_CONFIG_H
  28. #include <config.h>
  29. #endif
  30.  
  31. #include <cctype>
  32. #include <cstring>
  33.  
  34. #include <string>
  35.  
  36. #include <fstream.h>
  37. #include <iostream.h>
  38.  
  39. #include <SLList.h>
  40.  
  41. #include "Array-flags.h"
  42.  
  43. #include "mx-base.h"
  44. #include "Range.h"
  45. #include "str-vec.h"
  46.  
  47. #include "defun.h"
  48. #include "error.h"
  49. #include "gripes.h"
  50. #include "idx-vector.h"
  51. #include "mappers.h"
  52. #include "oct-map.h"
  53. #include "oct-obj.h"
  54. #include "pager.h"
  55. #include "pr-output.h"
  56. #include "sysdep.h"
  57. #include "pt-const.h"
  58. #include "pt-walk.h"
  59. #include "unwind-prot.h"
  60. #include "utils.h"
  61. #include "variables.h"
  62.  
  63. // We are likely to have a lot of tree_constant objects to allocate,
  64. // so make the grow_size large.
  65. octave_allocator
  66. tree_constant::allocator (sizeof (tree_constant), 1024);
  67.  
  68. Octave_map
  69. tree_constant::map_value (void) const
  70. {
  71.   return val.map_value ();
  72. }
  73.  
  74. void
  75. tree_constant::print (void)
  76. {
  77. }
  78.  
  79. void
  80. tree_constant::print (ostream& os, bool pr_as_read_syntax, bool pr_orig_text)
  81. {
  82.   if (pr_orig_text && ! orig_text.empty ())
  83.     os << orig_text;
  84.   else
  85.     val.print (os, pr_as_read_syntax);
  86. }
  87.  
  88. octave_value
  89. tree_constant::eval (bool print_result)
  90. {
  91.   if (print_result)
  92.     val.print ();
  93.  
  94.   return val;
  95. }
  96.  
  97. octave_value_list
  98. tree_constant::eval (bool, int, const octave_value_list& idx)
  99. {
  100.   octave_value_list retval;
  101.  
  102.   if (idx.length () >  0)
  103.     retval (0) = index (idx);
  104.   else
  105.     retval (0) = val;
  106.  
  107.   return retval;
  108. }
  109.  
  110. octave_value
  111. tree_constant::lookup_map_element (const string&, bool, bool)
  112. {
  113.   octave_value retval;
  114.   error ("tree_constant::lookup_map_element() not implemented");
  115.   return retval;
  116. }
  117.  
  118. octave_value
  119. tree_constant::lookup_map_element (SLList<string>&, bool, bool)
  120. {
  121.   octave_value retval;
  122.   error ("tree_constant::lookup_map_element() not implemented");
  123.   return retval;
  124. }
  125.  
  126. void
  127. tree_constant::stash_original_text (const string& s)
  128. {
  129.   orig_text = s;
  130. }
  131.  
  132. string
  133. tree_constant::original_text (void) const
  134. {
  135.   return orig_text;
  136. }
  137.  
  138. void
  139. tree_constant::accept (tree_walker& tw)
  140. {
  141.   tw.visit_constant (*this);
  142. }
  143.  
  144. /*
  145. ;;; Local Variables: ***
  146. ;;; mode: C++ ***
  147. ;;; End: ***
  148. */
  149.